<html>
<head>
<script src="/js/telepath.js"></script>
<script language=javascript>

function say () {

	var name = document.getElementById("name").value;
	var msg = document.getElementById("input").value;

	// write to stream
	TELEPATH.send("/chatroom", name + ": " + msg + "\n");
}

function recv (text) {

	document.getElementById("room").innerText = text;
}

function onload() {

	// create stream if it doesn't exist
	TELEPATH.send("/chatroom", "");

	// listen to stream
	TELEPATH.listen("/chatroom", 0, recv);
}

</script>
<body onload="onload();">
<div id=room>
</div><br>
name: <input type=text id=name><br>
say: <input type=text id=input>
<button onclick="say();">send</button>
</body>
</head>
</html>
